string=?, string<?, string>?, string<=?, string>=? - string comparison
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
SYNOPSIS
(string=? string1 string2 string3 ...)
(string<? string1 string2 string3 ...)
(string>? string1 string2 string3 ...)
(string<=? string1 string2 string3 ...)
(string>=? string1 string2 string3 ...)
DESCRIPTION
The
string=?
procedure returns #t if all the strings are the same length and
contain exactly the same characters in the same positions, otherwise
returns #f.
The ordering procedures return #t if their arguments are
(respectively): monotonically increasing, monotonically decreasing,
monotonically nondecreasing, or monotonically nonincreasing.
The behavior of the ordering procedures is different in R6RS and R7RS:
- R6RS
-
These procedures are the lexicographic extensions to strings of the
corresponding orderings on characters. For example,
string<?
is the lexicographic ordering on strings induced by the ordering
char<?
on characters. If two strings differ in length but are the same up to
the length of the shorter string, the shorter string is considered to
be lexicographically less than the longer string.
- R7RS
-
The ordering procedures compare strings in an implementation-defined
way. They may work the same as in R6RS, or they could use some other
ordering.
These predicates are required to be transitive. In all cases, a pair
of strings must satisfy exactly one of
string<?,
string=?,
and
string>?,
and must satisfy
string<=?
if and only if they do not satisfy
string>?
and
string>=?
if and only if they do not satisfy
string<?.
RETURN VALUES
These procedures return a single value; a boolean.
EXAMPLES
(string=? "Straße" "Strasse") => #f
(string<? "z" "ß") => #t
(string<? "z" "zz") => #t
(string<? "z" "Z") => #f
COMPATIBILITY
The basic idea of these procedures is the same in all RnRS revisions.
However, there are some differences.
R5RS and earlier reports only provided two-argument variants.
R6RS implementations all work the same.
R7RS implementations may lack support for some characters. The order
is also implementation-defined, with lexicographical ordering only
being one option.
ERRORS
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
-
The wrong number of arguments was passed or an argument was outside its domain.
- R7RS
-
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
SEE ALSO
char<?(3scm),
string-ci=?(3scm),
equal?(3scm)
STANDARDS
R4RS,
IEEE Scheme,
R5RS,
R6RS,
R7RS
HISTORY
These procedures first appeared in R2RS.
MacLisp had the
samepnamep
and
alphalessp
procedures that took two arguments and worked on both symbols and
strings.
AUTHORS
This page is part of the
scheme-manpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.